﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace AgileNYCWebService.Manager.Data.Table
{
    public class Contacts : BaseClass
    {
        public Contacts()
            : this(null)
        {

        }

        public Contacts(DataRow row)
            : base(row)
        {
            if (row != null)
            {
                if (row.Table.Columns.Contains("SentUserId"))
                    SentUserId = row["SentUserId"].GetInteger(-1);
                if (row.Table.Columns.Contains("ConfirmUserId"))
                    ConfirmUserId = row["ConfirmUserId"].GetInteger(-1);
                if (row.Table.Columns.Contains("SentDate") && row["SentDate"]!=null && !row["SentDate"].Equals(DBNull.Value) && !String.IsNullOrEmpty(row["SentDate"].ToString()))
                    SentDate = row["SentDate"].GetDateTime(default(DateTime));
                else
                    SentDate = null;

                if (row.Table.Columns.Contains("ConfirmDate") && row["ConfirmDate"] != null && !row["ConfirmDate"].Equals(DBNull.Value) && !String.IsNullOrEmpty(row["ConfirmDate"].ToString()))
                    ConfirmDate = row["ConfirmDate"].GetDateTime(default(DateTime));
                else
                    ConfirmDate = null;

                if (row.Table.Columns.Contains("Note") && row["Note"] != null && !row["Note"].Equals(DBNull.Value) && !String.IsNullOrEmpty(row["Note"].ToString()))
                    Note = row["Note"].GetString(string.Empty);
                else
                    Note = "";

                if (row.Table.Columns.Contains("NotificationStatus") && row["NotificationStatus"] != null && !row["NotificationStatus"].Equals(DBNull.Value) && !String.IsNullOrEmpty(row["NotificationStatus"].ToString()))
                    NotificationStatus = row["NotificationStatus"].GetBoolean(false);
                else
                    NotificationStatus = null;
            }
        }

        public int SentUserId { get; set; }
        public int ConfirmUserId { get; set; }
        public DateTime? SentDate { get; set; }
        public DateTime? ConfirmDate { get; set; }
        public string Note { get; set; }
        public bool? NotificationStatus { get; set; }
    }
}